<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的证书 | StudyRaid</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --bg-primary: #0d1117;
            --bg-secondary: #161b22;
            --bg-tertiary: #21262d;
            --text-primary: #f0f6fc;
            --text-secondary: #c9d1d9;
            --text-tertiary: #8b949e;
            --border-color: #30363d;
            --accent-color: #58a6ff;
            --success-color: #3fb950;
            --warning-color: #d29922;
            --danger-color: #f85149;
            --border-radius: 6px;
            --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
        }

        body {
            background-color: var(--bg-primary);
            color: var(--text-primary);
            line-height: 1.5;
        }

        .container {
            max-width: 1280px;
            margin: 0 auto;
            padding: 0 20px;
        }

        /* 导航栏样式 */
        header {
            background-color: var(--bg-secondary);
            border-bottom: 1px solid var(--border-color);
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .navbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px 0;
        }

        .logo {
            font-size: 24px;
            font-weight: 700;
            color: var(--text-primary);
            text-decoration: none;
            display: flex;
            align-items: center;
        }

        .logo i {
            margin-right: 10px;
            color: var(--accent-color);
        }

        .nav-links {
            display: flex;
            gap: 24px;
        }

        .nav-links a {
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 14px;
            transition: color 0.2s;
        }

        .nav-links a:hover,
        .nav-links a.active {
            color: var(--text-primary);
        }

        .user-menu {
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .search-box {
            position: relative;
        }

        .search-box input {
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            padding: 8px 12px;
            padding-left: 32px;
            color: var(--text-primary);
            width: 240px;
            font-size: 14px;
        }

        .search-box i {
            position: absolute;
            left: 10px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-tertiary);
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: var(--accent-color);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            cursor: pointer;
        }

        /* 个人中心布局 */
        .profile-container {
            display: grid;
            grid-template-columns: 300px 1fr;
            gap: 24px;
            margin: 24px 0;
        }

        /* 侧边栏 */
        .profile-sidebar {
            background-color: var(--bg-secondary);
            border-radius: var(--border-radius);
            border: 1px solid var(--border-color);
            overflow: hidden;
            height: fit-content;
            position: sticky;
            top: 90px;
        }

        .profile-info {
            padding: 24px;
            text-align: center;
            border-bottom: 1px solid var(--border-color);
        }

        .profile-avatar {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            background-color: var(--accent-color);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 28px;
            font-weight: bold;
            margin: 0 auto 16px;
        }

        .profile-name {
            font-size: 20px;
            font-weight: 600;
            margin-bottom: 4px;
        }

        .profile-username {
            color: var(--text-tertiary);
            font-size: 14px;
            margin-bottom: 16px;
        }

        .profile-bio {
            color: var(--text-secondary);
            font-size: 14px;
            line-height: 1.5;
        }

        .profile-stats {
            display: flex;
            justify-content: space-around;
            padding: 16px;
            border-bottom: 1px solid var(--border-color);
        }

        .stat-item {
            text-align: center;
        }

        .stat-value {
            font-size: 20px;
            font-weight: 600;
            color: var(--accent-color);
        }

        .stat-label {
            font-size: 12px;
            color: var(--text-tertiary);
        }

        .profile-menu {
            padding: 16px 0;
        }

        .menu-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 20px;
            color: var(--text-secondary);
            text-decoration: none;
            transition: all 0.2s;
            cursor: pointer;
        }

        .menu-item:hover,
        .menu-item.active {
            background-color: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .menu-item i {
            width: 20px;
            text-align: center;
        }

        /* 主要内容区域 */
        .profile-content {
            background-color: var(--bg-secondary);
            border-radius: var(--border-radius);
            border: 1px solid var(--border-color);
            overflow: hidden;
        }

        .content-section {
            padding: 24px;
            border-bottom: 1px solid var(--border-color);
        }

        .content-section:last-child {
            border-bottom: none;
        }

        .section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .section-title {
            font-size: 20px;
            font-weight: 600;
        }

        .section-action {
            color: var(--accent-color);
            font-size: 14px;
            text-decoration: none;
        }

        /* 证书筛选器 */
        .certificate-filters {
            display: flex;
            gap: 12px;
            margin-bottom: 24px;
            flex-wrap: wrap;
        }

        .filter-btn {
            background-color: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: var(--border-radius);
            padding: 8px 16px;
            color: var(--text-secondary);
            font-size: 14px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .filter-btn:hover {
            background-color: var(--bg-secondary);
            border-color: var(--text-tertiary);
        }

        .filter-btn.active {
            background-color: var(--accent-color);
            border-color: var(--accent-color);
            color: white;
        }

        /* 证书网格 */
        .certificates-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 24px;
        }

        .certificate-card {
            background-color: var(--bg-tertiary);
            border-radius: var(--border-radius);
            overflow: hidden;
            transition: transform 0.2s, box-shadow 0.2s;
            border: 1px solid var(--border-color);
        }

        .certificate-card:hover {
            transform: translateY(-4px);
            box-shadow: var(--shadow);
        }

        .certificate-header {
            padding: 20px;
            text-align: center;
            background: linear-gradient(135deg, #1a1f2e, #0d1117);
            border-bottom: 1px solid var(--border-color);
        }

        .certificate-icon {
            width: 64px;
            height: 64px;
            border-radius: 50%;
            background-color: rgba(88, 166, 255, 0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 16px;
            color: var(--accent-color);
            font-size: 24px;
        }

        .certificate-title {
            font-size: 18px;
            font-weight: 600;
            margin-bottom: 8px;
        }

        .certificate-issuer {
            color: var(--text-tertiary);
            font-size: 14px;
        }

        .certificate-body {
            padding: 20px;
        }

        .certificate-info {
            display: flex;
            flex-direction: column;
            gap: 12px;
            margin-bottom: 20px;
        }

        .info-item {
            display: flex;
            justify-content: space-between;
        }

        .info-label {
            color: var(--text-tertiary);
            font-size: 14px;
        }

        .info-value {
            font-size: 14px;
            font-weight: 500;
        }

        .certificate-actions {
            display: flex;
            gap: 8px;
        }

        .btn {
            padding: 8px 16px;
            border-radius: var(--border-radius);
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            border: none;
            transition: all 0.2s;
            text-align: center;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            flex: 1;
        }

        .btn-primary {
            background-color: var(--accent-color);
            color: white;
        }

        .btn-primary:hover {
            background-color: #4a93e0;
        }

        .btn-secondary {
            background-color: var(--bg-secondary);
            color: var(--text-primary);
            border: 1px solid var(--border-color);
        }

        .btn-secondary:hover {
            background-color: var(--bg-tertiary);
        }

        /* 空状态 */
        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: var(--text-tertiary);
        }

        .empty-state i {
            font-size: 64px;
            margin-bottom: 16px;
            opacity: 0.5;
        }

        .empty-state h3 {
            font-size: 20px;
            margin-bottom: 8px;
            color: var(--text-secondary);
        }

        /* 证书详情模态框 */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            z-index: 1000;
            align-items: center;
            justify-content: center;
        }

        .modal-content {
            background-color: var(--bg-secondary);
            border-radius: var(--border-radius);
            border: 1px solid var(--border-color);
            width: 90%;
            max-width: 600px;
            max-height: 90vh;
            overflow-y: auto;
        }

        .modal-header {
            padding: 20px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-title {
            font-size: 20px;
            font-weight: 600;
        }

        .modal-close {
            background: none;
            border: none;
            color: var(--text-tertiary);
            font-size: 20px;
            cursor: pointer;
        }

        .modal-body {
            padding: 20px;
        }

        .certificate-preview {
            background: linear-gradient(135deg, #1a1f2e, #0d1117);
            border-radius: var(--border-radius);
            padding: 30px;
            text-align: center;
            margin-bottom: 20px;
            border: 1px solid var(--border-color);
        }

        .certificate-logo {
            font-size: 48px;
            color: var(--accent-color);
            margin-bottom: 20px;
        }

        .certificate-preview-title {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 10px;
        }

        .certificate-preview-subtitle {
            color: var(--text-tertiary);
            margin-bottom: 20px;
        }

        .certificate-preview-name {
            font-size: 20px;
            font-weight: 600;
            margin-bottom: 10px;
        }

        .certificate-preview-date {
            color: var(--text-tertiary);
            margin-bottom: 30px;
        }

        .certificate-preview-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-top: 1px solid var(--border-color);
            padding-top: 20px;
        }

        .signature {
            text-align: left;
        }

        .signature-name {
            font-weight: 600;
            margin-bottom: 4px;
        }

        .signature-title {
            color: var(--text-tertiary);
            font-size: 14px;
        }

        /* 页脚 */
        footer {
            border-top: 1px solid var(--border-color);
            padding: 24px 0;
            margin-top: 40px;
            text-align: center;
            color: var(--text-tertiary);
            font-size: 14px;
        }

        /* 响应式设计 */
        @media (max-width: 1024px) {
            .profile-container {
                grid-template-columns: 1fr;
            }

            .profile-sidebar {
                order: -1;
                position: static;
            }
        }

        @media (max-width: 768px) {
            .navbar {
                flex-direction: column;
                gap: 16px;
            }

            .nav-links {
                order: 3;
                width: 100%;
                justify-content: center;
            }

            .search-box input {
                width: 200px;
            }

            .certificates-grid {
                grid-template-columns: 1fr;
            }

            .certificate-actions {
                flex-direction: column;
            }

            .certificate-actions .btn {
                width: 100%;
                justify-content: center;
            }
        }
    </style>
</head>

<body>
    <!-- 导航栏 -->
    <header>
        <div class="container">
            <nav class="navbar">
                <a href="index.html" class="logo">
                    <i class="fas fa-graduation-cap"></i>
                    StudyRaid
                </a>

                <div class="nav-links">
                    <a href="my-courses.html">我的课程</a>
                    <a href="explore.html">发现</a>
                    <a href="learning-path.html">学习路径</a>
                    <a href="profile.html" class="active">个人中心</a>
                </div>

                <div class="user-menu">
                    <div class="search-box">
                        <i class="fas fa-search"></i>
                        <input type="text" placeholder="搜索证书..." id="certificateSearch">
                    </div>
                    <div class="user-avatar">JS</div>
                </div>
            </nav>
        </div>
    </header>

    <!-- 个人中心内容 -->
    <main class="container">
        <div class="profile-container">
            <!-- 侧边栏 -->
            <div class="profile-sidebar">
                <div class="profile-info">
                    <div class="profile-avatar">JS</div>
                    <h2 class="profile-name">张三</h2>
                    <p class="profile-username">@zhangsan</p>
                    <p class="profile-bio">前端开发工程师 | 终身学习者 | 热爱编程与分享</p>
                </div>

                <div class="profile-stats">
                    <div class="stat-item">
                        <div class="stat-value">5</div>
                        <div class="stat-label">证书</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-value">65%</div>
                        <div class="stat-label">完成率</div>
                    </div>
                    <div class="stat-item">
                        <div class="stat-value">42</div>
                        <div class="stat-label">学习天数</div>
                    </div>
                </div>

                <div class="profile-menu">
                    <a href="profile.html" class="menu-item">
                        <i class="fas fa-user"></i>
                        <span>个人信息</span>
                    </a>
                    <a href="my-stat.html" class="menu-item">
                        <i class="fas fa-chart-line"></i>
                        <span>学习统计</span>
                    </a>
                    <a href="my-cert.html" class="menu-item active">
                        <i class="fas fa-certificate"></i>
                        <span>我的证书</span>
                    </a>
                    <a href="account-settings.html" class="menu-item">
                        <i class="fas fa-cog"></i>
                        <span>账户设置</span>
                    </a>
                    <a href="help.html" class="menu-item">
                        <i class="fas fa-question-circle"></i>
                        <span>帮助与支持</span>
                    </a>
                    <a href="logout.html" class="menu-item">
                        <i class="fas fa-sign-out-alt"></i>
                        <span>退出登录</span>
                    </a>
                </div>
            </div>

            <!-- 主要内容区域 -->
            <div class="profile-content">
                <!-- 证书列表部分 -->
                <div class="content-section">
                    <div class="section-header">
                        <h3 class="section-title">我的证书</h3>
                        <div class="certificate-count">共 5 个证书</div>
                    </div>

                    <div class="certificate-filters">
                        <button class="filter-btn active" data-filter="all">全部</button>
                        <button class="filter-btn" data-filter="frontend">前端开发</button>
                        <button class="filter-btn" data-filter="backend">后端开发</button>
                        <button class="filter-btn" data-filter="data">数据科学</button>
                        <button class="filter-btn" data-filter="mobile">移动开发</button>
                    </div>

                    <div class="certificates-grid" id="certificatesGrid">
                        <!-- 证书卡片 1 -->
                        <div class="certificate-card" data-category="frontend">
                            <div class="certificate-header">
                                <div class="certificate-icon">
                                    <i class="fab fa-js"></i>
                                </div>
                                <h4 class="certificate-title">JavaScript 高级编程</h4>
                                <p class="certificate-issuer">StudyRaid</p>
                            </div>
                            <div class="certificate-body">
                                <div class="certificate-info">
                                    <div class="info-item">
                                        <span class="info-label">颁发日期</span>
                                        <span class="info-value">2023-10-15</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">证书编号</span>
                                        <span class="info-value">SR-JS-20231015</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">课程时长</span>
                                        <span class="info-value">12 小时</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">完成率</span>
                                        <span class="info-value">100%</span>
                                    </div>
                                </div>
                                <div class="certificate-actions">
                                    <button class="btn btn-primary view-certificate" data-id="1">
                                        <i class="fas fa-eye"></i> 查看证书
                                    </button>
                                    <button class="btn btn-secondary download-certificate" data-id="1">
                                        <i class="fas fa-download"></i> 下载
                                    </button>
                                </div>
                            </div>
                        </div>

                        <!-- 证书卡片 2 -->
                        <div class="certificate-card" data-category="backend">
                            <div class="certificate-header">
                                <div class="certificate-icon">
                                    <i class="fab fa-node-js"></i>
                                </div>
                                <h4 class="certificate-title">Node.js 与 Express</h4>
                                <p class="certificate-issuer">StudyRaid</p>
                            </div>
                            <div class="certificate-body">
                                <div class="certificate-info">
                                    <div class="info-item">
                                        <span class="info-label">颁发日期</span>
                                        <span class="info-value">2023-09-22</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">证书编号</span>
                                        <span class="info-value">SR-NODE-20230922</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">课程时长</span>
                                        <span class="info-value">15 小时</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">完成率</span>
                                        <span class="info-value">100%</span>
                                    </div>
                                </div>
                                <div class="certificate-actions">
                                    <button class="btn btn-primary view-certificate" data-id="2">
                                        <i class="fas fa-eye"></i> 查看证书
                                    </button>
                                    <button class="btn btn-secondary download-certificate" data-id="2">
                                        <i class="fas fa-download"></i> 下载
                                    </button>
                                </div>
                            </div>
                        </div>

                        <!-- 证书卡片 3 -->
                        <div class="certificate-card" data-category="data">
                            <div class="certificate-header">
                                <div class="certificate-icon">
                                    <i class="fab fa-python"></i>
                                </div>
                                <h4 class="certificate-title">Python 数据分析</h4>
                                <p class="certificate-issuer">StudyRaid</p>
                            </div>
                            <div class="certificate-body">
                                <div class="certificate-info">
                                    <div class="info-item">
                                        <span class="info-label">颁发日期</span>
                                        <span class="info-value">2023-08-10</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">证书编号</span>
                                        <span class="info-value">SR-PY-20230810</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">课程时长</span>
                                        <span class="info-value">18 小时</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">完成率</span>
                                        <span class="info-value">100%</span>
                                    </div>
                                </div>
                                <div class="certificate-actions">
                                    <button class="btn btn-primary view-certificate" data-id="3">
                                        <i class="fas fa-eye"></i> 查看证书
                                    </button>
                                    <button class="btn btn-secondary download-certificate" data-id="3">
                                        <i class="fas fa-download"></i> 下载
                                    </button>
                                </div>
                            </div>
                        </div>

                        <!-- 证书卡片 4 -->
                        <div class="certificate-card" data-category="mobile">
                            <div class="certificate-header">
                                <div class="certificate-icon">
                                    <i class="fab fa-react"></i>
                                </div>
                                <h4 class="certificate-title">React Native 开发</h4>
                                <p class="certificate-issuer">StudyRaid</p>
                            </div>
                            <div class="certificate-body">
                                <div class="certificate-info">
                                    <div class="info-item">
                                        <span class="info-label">颁发日期</span>
                                        <span class="info-value">2023-07-05</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">证书编号</span>
                                        <span class="info-value">SR-RN-20230705</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">课程时长</span>
                                        <span class="info-value">20 小时</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">完成率</span>
                                        <span class="info-value">100%</span>
                                    </div>
                                </div>
                                <div class="certificate-actions">
                                    <button class="btn btn-primary view-certificate" data-id="4">
                                        <i class="fas fa-eye"></i> 查看证书
                                    </button>
                                    <button class="btn btn-secondary download-certificate" data-id="4">
                                        <i class="fas fa-download"></i> 下载
                                    </button>
                                </div>
                            </div>
                        </div>

                        <!-- 证书卡片 5 -->
                        <div class="certificate-card" data-category="frontend">
                            <div class="certificate-header">
                                <div class="certificate-icon">
                                    <i class="fab fa-vuejs"></i>
                                </div>
                                <h4 class="certificate-title">Vue.js 实战开发</h4>
                                <p class="certificate-issuer">StudyRaid</p>
                            </div>
                            <div class="certificate-body">
                                <div class="certificate-info">
                                    <div class="info-item">
                                        <span class="info-label">颁发日期</span>
                                        <span class="info-value">2023-06-18</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">证书编号</span>
                                        <span class="info-value">SR-VUE-20230618</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">课程时长</span>
                                        <span class="info-value">14 小时</span>
                                    </div>
                                    <div class="info-item">
                                        <span class="info-label">完成率</span>
                                        <span class="info-value">100%</span>
                                    </div>
                                </div>
                                <div class="certificate-actions">
                                    <button class="btn btn-primary view-certificate" data-id="5">
                                        <i class="fas fa-eye"></i> 查看证书
                                    </button>
                                    <button class="btn btn-secondary download-certificate" data-id="5">
                                        <i class="fas fa-download"></i> 下载
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <!-- 证书详情模态框 -->
    <div class="modal" id="certificateModal">
        <div class="modal-content">
            <div class="modal-header">
                <h3 class="modal-title">证书详情</h3>
                <button class="modal-close" id="modalClose">
                    <i class="fas fa-times"></i>
                </button>
            </div>
            <div class="modal-body">
                <div class="certificate-preview">
                    <div class="certificate-logo">
                        <i class="fas fa-graduation-cap"></i>
                    </div>
                    <h3 class="certificate-preview-title" id="previewTitle">JavaScript 高级编程</h3>
                    <p class="certificate-preview-subtitle" id="previewSubtitle">StudyRaid 认证证书</p>
                    <p class="certificate-preview-name">张三</p>
                    <p class="certificate-preview-date" id="previewDate">2023年10月15日</p>
                    <p>成功完成 JavaScript 高级编程课程，共计 12 小时的学习内容，表现优异，特发此证。</p>
                    <div class="certificate-preview-footer">
                        <div class="signature">
                            <div class="signature-name">StudyRaid 认证委员会</div>
                            <div class="signature-title">认证机构</div>
                        </div>
                        <div class="certificate-id" id="previewId">证书编号: SR-JS-20231015</div>
                    </div>
                </div>
                <div class="certificate-actions">
                    <button class="btn btn-primary" id="downloadFromModal">
                        <i class="fas fa-download"></i> 下载证书 (PDF)
                    </button>
                    <button class="btn btn-secondary" id="shareCertificate">
                        <i class="fas fa-share-alt"></i> 分享证书
                    </button>
                </div>
            </div>
        </div>
    </div>

    <!-- 页脚 -->
    <footer>
        <div class="container">
            <p>© 2023 StudyRaid. 保留所有权利。</p>
            <p>采用 GitHub 深色风格设计</p>
        </div>
    </footer>

    <script>
        // 菜单项点击功能
        document.querySelectorAll('.menu-item').forEach(item => {
            item.addEventListener('click', function () {
                document.querySelectorAll('.menu-item').forEach(i => {
                    i.classList.remove('active');
                });
                this.classList.add('active');
            });
        });

        // 证书筛选功能
        document.querySelectorAll('.filter-btn').forEach(button => {
            button.addEventListener('click', function () {
                document.querySelectorAll('.filter-btn').forEach(btn => {
                    btn.classList.remove('active');
                });
                this.classList.add('active');

                const filter = this.dataset.filter;
                const certificates = document.querySelectorAll('.certificate-card');

                certificates.forEach(certificate => {
                    if (filter === 'all' || certificate.dataset.category === filter) {
                        certificate.style.display = 'block';
                    } else {
                        certificate.style.display = 'none';
                    }
                });

                // 更新证书计数
                updateCertificateCount();
            });
        });

        // 搜索功能
        document.getElementById('certificateSearch').addEventListener('input', function () {
            const searchTerm = this.value.toLowerCase();
            const certificates = document.querySelectorAll('.certificate-card');

            certificates.forEach(certificate => {
                const title = certificate.querySelector('.certificate-title').textContent.toLowerCase();
                if (title.includes(searchTerm)) {
                    certificate.style.display = 'block';
                } else {
                    certificate.style.display = 'none';
                }
            });

            // 更新证书计数
            updateCertificateCount();
        });

        // 更新证书计数
        function updateCertificateCount() {
            const visibleCertificates = document.querySelectorAll('.certificate-card[style="display: block"]').length;
            const totalCertificates = document.querySelectorAll('.certificate-card').length;
            const countElement = document.querySelector('.certificate-count');

            if (visibleCertificates === totalCertificates) {
                countElement.textContent = `共 ${totalCertificates} 个证书`;
            } else {
                countElement.textContent = `共 ${visibleCertificates}/${totalCertificates} 个证书`;
            }
        }

        // 证书详情模态框
        const modal = document.getElementById('certificateModal');
        const modalClose = document.getElementById('modalClose');
        const viewButtons = document.querySelectorAll('.view-certificate');
        const downloadButtons = document.querySelectorAll('.download-certificate');
        const downloadFromModal = document.getElementById('downloadFromModal');
        const shareButton = document.getElementById('shareCertificate');

        // 证书数据
        const certificateData = {
            1: {
                title: "JavaScript 高级编程",
                date: "2023年10月15日",
                id: "SR-JS-20231015",
                duration: "12 小时"
            },
            2: {
                title: "Node.js 与 Express",
                date: "2023年9月22日",
                id: "SR-NODE-20230922",
                duration: "15 小时"
            },
            3: {
                title: "Python 数据分析",
                date: "2023年8月10日",
                id: "SR-PY-20230810",
                duration: "18 小时"
            },
            4: {
                title: "React Native 开发",
                date: "2023年7月5日",
                id: "SR-RN-20230705",
                duration: "20 小时"
            },
            5: {
                title: "Vue.js 实战开发",
                date: "2023年6月18日",
                id: "SR-VUE-20230618",
                duration: "14 小时"
            }
        };

        // 查看证书
        viewButtons.forEach(button => {
            button.addEventListener('click', function () {
                const certificateId = this.dataset.id;
                const data = certificateData[certificateId];

                document.getElementById('previewTitle').textContent = data.title;
                document.getElementById('previewDate').textContent = data.date;
                document.getElementById('previewId').textContent = `证书编号: ${data.id}`;

                modal.style.display = 'flex';
            });
        });

        // 下载证书
        downloadButtons.forEach(button => {
            button.addEventListener('click', function () {
                const certificateId = this.dataset.id;
                alert(`开始下载证书 ${certificateId} 的PDF文件`);
                // 实际应用中这里会触发文件下载
            });
        });

        // 从模态框下载证书
        downloadFromModal.addEventListener('click', function () {
            const certificateId = document.getElementById('previewId').textContent.split(': ')[1];
            alert(`开始下载证书 ${certificateId} 的PDF文件`);
            // 实际应用中这里会触发文件下载
        });

        // 分享证书
        shareButton.addEventListener('click', function () {
            const certificateTitle = document.getElementById('previewTitle').textContent;
            const certificateId = document.getElementById('previewId').textContent.split(': ')[1];

            if (navigator.share) {
                navigator.share({
                    title: `我的证书: ${certificateTitle}`,
                    text: `我在 StudyRaid 上获得了 "${certificateTitle}" 证书，证书编号: ${certificateId}`,
                    url: window.location.href
                })
                    .then(() => console.log('分享成功'))
                    .catch((error) => console.log('分享失败', error));
            } else {
                alert('您的浏览器不支持分享功能，请手动复制链接分享');
            }
        });

        // 关闭模态框
        modalClose.addEventListener('click', function () {
            modal.style.display = 'none';
        });

        // 点击模态框外部关闭
        window.addEventListener('click', function (event) {
            if (event.target === modal) {
                modal.style.display = 'none';
            }
        });
    </script>
</body>

</html>